package com.upb.webserver.common.pojo.order;

import com.upb.webserver.common.pojo.rest.fabric.data.req.ReqCreateChainDTO;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import java.util.List;

@Data
@EqualsAndHashCode(callSuper = true)
public class ReqAddWorkOrderOfNewChainVO extends BaseNewChainVO {
    //----------------------
    //-----fabric properties------
    private List<ReqCreateChainDTO.KafkaBroker> kafkaBrokers; //共识类型(consensusType)为kafka时必填
    private List<FabricOrderOrg> fabricOrderOrgList;
    private List<FabricPeerOrg> fabricPeerOrgList;


    //----------------------
    //-----fisco properties-------
    //----------------------
    @Min(value = 0,message = "field value can only be 0 or 1")
    @Max(value = 1,message = "field value can only be 0 or 1")
    private Byte encryptionId;//证书加密类型：0，非国密；1，国密
    private List<NewFiscoChainOrg> fiscoOrgList;

    @Data
    public static class NewFiscoChainHost {
        private Integer fiscoHostId;
        private int nodeCount;//主机上部署节点数量
    }

    @Data
    public static class NewFiscoChainOrg {
        private Integer orgId;
        private Integer companyId;
        private List<NewFiscoChainHost> fiscoHostList;//部署的主机信息列表
    }


    @Data
    public static class FabricOrderOrg {
        private Integer orgId;
        private Integer companyId;
        private List<FabricNode> orderNodeList;
    }

    @Data
    public static class FabricPeerOrg {
        private Integer orgId;
        private Integer companyId;
        private FabricNode caNode;
        private String caPassWd;
        private String caUserName;
        private Integer initUserCount;
        private List<FabricNode> peerNodeList;
    }


    @Data
    public static class FabricNode {
        private Integer hostId;
        private String nodeName;
    }
}
